package com.jinsi.controller.ylt;

import com.jinsi.constant.YltConstant;
import com.jinsi.pojo.SyCourseLog;
import com.jinsi.service.ylt.ZeroMonsyService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jinsi.util.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;


/**
 * @ClassName ZeroMonsyController
 * @Content 零消费用户Controller
 * @Author 姚龙腾
 * @Date 2022/10/12 11:53
 */
@RestController
@RequestMapping("/YltUser")
@Slf4j
public class ZeroMonsyController {
    @Autowired
    private ZeroMonsyService zeroMonsyService;


    /**
     * 获取所有零消费用户信息展示于列表
     * @param page
     * @param limit
     * @return R
     */
    @RequestMapping("/UserManage/getZeroMonsy")
    public R getZeroMonsy(Integer page, Integer limit){
        PageHelper.startPage(page,limit);
        List<SyCourseLog> list = zeroMonsyService.getAll();
        PageInfo<SyCourseLog> pageInfo = new PageInfo<>(list);
        return R.custom(YltConstant.LAYUI_CODE,
                YltConstant.LAYUI_MSG,
                pageInfo.getList(),
                pageInfo.getTotal());
    }


    /**
     * 根据输入信息进行模糊查询
     * @param page
     * @param limit
     * @param userName
     * @param userAccount
     * @param userCreateDate
     * @return R
     */
    @RequestMapping("/UserManage/getZeroMonsyByLike")
    public R getZeroMonsyByLike(Integer page, Integer limit, String userName, String userAccount, String userCreateDate){
        PageHelper.startPage(page,limit);
        List<SyCourseLog> list = zeroMonsyService.getAllByLike(userName, userAccount, userCreateDate);
        PageInfo<SyCourseLog> pageInfo = new PageInfo<>(list);
        return R.custom(YltConstant.LAYUI_CODE,
                YltConstant.LAYUI_MSG,
                pageInfo.getList(),
                pageInfo.getTotal());
    }



}
